package com.fastloan.mgt.product.basics.controller;

import com.fastloan.mgt.product.basics.model.ProductFile;
import com.fastloan.mgt.product.basics.service.ProductFileService;
import com.kawins.base.baseabs.BaseController;
import com.kawins.result.ResultEnum;
import com.kawins.result.ResultTo;
import com.kawins.supers.file.core.FileLoadBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 产品文件
 *
 * @author chenkai
 *         createTime 2017-11-2017/11/6 17:31
 */
@RestController
@RequestMapping("/api/web/productFile")
public class ProductFileController extends BaseController<ProductFile> {
    @Autowired
    private ProductFileService productFileService;

    /**
     * 上传产品文件
     * @param productId
     * @param fileType
     * @param file
     * @return
     */
    @PostMapping
    public ResultTo uploadProductFile(String productId, Integer fileType, @PathVariable MultipartFile[] file) {
        List<FileLoadBean> list = productFileService.uploadProductFile(productId, fileType, file);
        return list != null ? new ResultTo().setData(list) : new ResultTo(ResultEnum.OPERATION_FAILED);
    }
}
